package com.niit.serviceorder.mapper;

import com.niit.common.entity.TbOrder;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TbOrderMapper {

    @Select("SELECT * FROM tb_order")
    List<TbOrder> selectAll();

    @Select("SELECT * FROM tb_order WHERE id = #{id}")
    TbOrder selectById(Long id);

    @Insert("INSERT INTO tb_order (user_id, name, price, num) VALUES (#{userId}, #{name}, #{price}, #{num})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(TbOrder order); // 修改返回值为int

    @Update("UPDATE tb_order SET user_id = #{userId}, name = #{name}, price = #{price}, num = #{num} WHERE id = #{id}")
    int update(TbOrder order); // 修改返回值为int

    @Delete("DELETE FROM tb_order WHERE id = #{id}")
    int deleteById(Long id); // 修改返回值为int
}